// pages/aim/aim.js
var util = require('../../utils/util');
var that;
Page({

  /**
   * 页面的初始数据
   */
  data: {
  progre:'20%',
  selectList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that = this;
    var nowQuestion = wx.getStorageSync('nowQuestion');
    util.sendRequest('WxQuestionDetail', { id: nowQuestion.id},function(resp){
        if(resp&&resp.code==0){
          that.setData({ selectList:resp.result});
        }else{
          util.wxModalAlert({ content: resp.text},null,null);
        }
    },'加载中...',function(){

    });

  },
  nextStep:function(event){
 
    var obj = event.target.dataset.obj;
    var nowQuestion = wx.getStorageSync('nowQuestion');
    nowQuestion.value = obj.value;
    nowQuestion.answer = obj.optional;
    var questionInfo = wx.getStorageSync('questionInfo') || [];
    if (questionInfo instanceof Array) {
      questionInfo.push(nowQuestion);
    } else {
      var arr = [];
      arr.push(questionInfo);
      arr.push(nowQuestion);
      questionInfo = arr;
    }
    wx.setStorageSync('questionInfo', questionInfo);
    util.nextQuestion(nowQuestion.location);

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})